Rearrange project to follow standard C project syntax

I moved the function definitions from header (.h) files to source (.c) files, then updated the headers to declare the public interface into the sources. I probably left the headers with too many functions defined, and I definitely left them including too many other headers. But they're better than they were.

DEBUG_LEVEL being defined in headers was definitely a problem when it got to link time, so I moved that definition into the two main programs, then made it accessible through an extern definition in debug.h.

I also updated this code so that it can build under either Linux or Mac OSX (at least with developer tools).