Bug 1031122: Support return values in callback functions

Callback functions now return a value to indicate success or failure
and control the further behaviour of the event loop. On success, the
loop can either continue, continue with polling file descriptors anew,
or exit. On failure, the loop can abort.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Bug 1031122: Support uninit callback in event loop

The event loop now calls a user-supplied function for cleaning
up after leaving the loop.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Bug 1031122: Cleanups

This patch patch adds spaces around binary operators, fixes pointer
declarations, and removes unecessary empty lines.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Bug 1031122: Allocate fd-state array dynamically

The entries in the fd-state array are now allocated dynamically. The
array grows in size along power-of-2 values.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Bug 1031122: Support pre-JB logging macros

Android before version 4.1 used different macros for logging. On
these older platforms, libfdio now builds using these macros. The
caller is supposed to use the new macros from JB and later though.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>