A library of generic C modules
The libmba package is a collection of mostly independent C modules potentially useful to any project. There are the usual ADTs including a linkedlist, hashmap, pool, stack, and varray, a flexible memory allocator, CSV parser, path canonicalization routine, I18N text abstraction, configuration file module, portable semaphores, condition variables and more. The code is designed so that individual modules can be integrated into existing codebases rather than requiring the user to commit to the entire library. The code has no typedefs, few comments, and extensive man pages and HTML documentation.
Browse The Source
Similar ProjectsThese projects look similar in purpose to libmba although in most cases that has not be confirmed and their presence here is in not necessarily an endorsement of quality. They are listed here (not in any particular order) only to help developers focus their search.
Matt's C Utility Library
Fri Apr 29, 2005
Portability of libmba has been greatly improved. It has been compiled and tested (albeit not extensively on all platforms) on OSF1, HP-UX , Linux, Mac OS X , and FreeBSD with gcc, DECC, and aC++. There have also been the following modifications and enhancements.
Sat Aug 28, 2004
Two bugs have been found and fixed in the csv module. If a non-ASCII character was read with csv_row_parse, parsing would stop prematurely due to a signedness error. The csv module now uses unsigned char throughout to properly support internationalized text. Note csv_row_fread was unaffected by this bug. Second, if the character preceeding EOF was a double quote (as opposed to a newline) an error would occur. The csv module will now correctly process the final element.
Also related, a few example programs are now included with the distribution. One such example is the csvprint utility which prints data in a csv file using a format string.
examples$ ./csvprint data.csv "%2|%1|FOO(%2)\n" three|two|FOO(three) ...This is suprisingly useful for reordering fields, generating source code, etc.
The bitset_find_first function will now set errno to ENOENT if the target bit was not found.
Some issues regarding the initialization of svsem(3m) semaphores have been fixed. The module should now properly handle the initialization race outlined in Stevens' UNPv2 in addition to the scenario where a semaphore is removed during initialization.
Finally the eval(3m) module now provides for a context parameter to be specifed that will be passed to the user supplied symlook function. This is necessary for full reentrance.
All documentation has been updated accordingly.
Fri May 21, 2004
The sho_loop function now accepts a pattern vector and timeout like sho_expect and the cfg module has been modified to more closely support Java Properties escape sequences for spaces and Unicode characters.
Thu May 6, 2004
The purpose of this project is to provide generic C implementations of concepts elemental to a wide variety of programming problems. The latest addition to libmba is the diff module and it is a fine example of a non-trivial algorithm that is crucial to the function and efficiency of many common applications such as spell checkers, version control systems, spam filters, speech recognition, and more. The code is generic such that anything that can be indexed and compared with user supplied callbacks can be used such as strings, linked lists, pointers to lines in files, etc.
The algorithm is perhaps best known for it's use in the GNU diff(1) program for generating a "diff" of two files. Formally it is known as the shortest edit script (SES) problem and is solved efficiently using the dynamic programming algorithm described by Myers  and in linear space with the Hirschberg refinement. The objective is to compute the minimum set of edit operations necessary to transform sequence A of length N into B of lenth M. This can be performed in O((N+M)D^2) expected time where D is the edit distance (the number of elements deleted and inserted).
 E. Myers, ``An O(ND) Difference Algorithm and Its Variations,'' Algorithmica 1, 2 (1986), 251-266. http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps
Also, in this release, the path module, which has been in libmba for a some time, is now documented. This module provides a high quality filesystem path canonicalization routine. Path canonicalization is notoriously unforgiving because the parsing rountine is complex and yet it is not uncommon for programs to be required to accept paths from potentially malicous sources. This implementation uses a state machine approach to reduce complexity and has been tested with a wide range of inputs (see tcase/test/data/PathCanonExamples.data). Certain conditions are enforced that minimize the potential for exploits. For exmaple, only one input character is examined with each iteration of the outer loop so that it can be certain that the slim and dlim limit pointers are checked with the advance of every input character. A canonicalized path cannot begin with a path separator unless the input began with a path separator. Because of the state machine structure, if there is a flaw in the implementation the fix is more likely to be a local adjustment which limits the potential for creating new flaws.
Last updated Apr 29, 2005
API documentation and website generated with CSytleX
Copyright © 2004 Michael B Allen <mba2000 ioplex.com>
validate this page