API extension and portability

* added user callback to API so that the application does not need to buffer large arrays of offsets and lengths
* written in ANSI c for portability on non-gcc compilers
* reduced footprint size by 50% by using switch statement instead of tables
* does not allocate any memory at all, except return code
* added c++ support